/*
** $Id: xaux_ext_lookup.c,v 1.37 2003/02/22 04:34:18 rogerso Exp $
**
** SWin X Auxilliary Objects
** External module -- IM preedit/lookup
*/

#ifdef HAVE_CONFIG_H
# include <config.h>
#endif /* HAVE_CONFIG_H */

#define DONT_UNPARENT 1
/* optimization: we don't use the horizontal lookup anymore, hence no need i
** to recycle the GtkLabels, and no need to unparent/reparent them. */
#define USE_PREEDIT_AUX 1

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <gtk/gtk.h>
#include <libintl.h>
#include <unisocket.h>
#include <standard_im.h>

#include "imm.h"
#include "ime.h"
#include "im.h"
#include "ui.h"

#define VOID_IM_ID 0xFFFF
#define VOID_IC_ID 0xFFFF

int
main(int argc, char *argv[])
{
#if DEBUG
	fprintf(stderr, "DEFAULT UI : staring unihan default ui ...\n");
#endif

	/* We will always use a UTF-8 locale to prevent stuffup */
	//setenv("LC_ALL", "zh_CN.UTF-8", 1);
	gtk_set_locale();

	/* Initialize the i18n stuff */
	bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
	bindtextdomain(GETTEXT_PACKAGE, GNOMELOCALEDIR);
	textdomain(GETTEXT_PACKAGE);

	gtk_init(&argc, &argv);

	ui_init_attributes();
	ui_init_lookup_data();
	ui_init_preedit_window();
	ui_init_lu_horz_window();
	ui_init_lu_vert_window();

	//gtk_widget_realize(preedit->window);

	if (!unisocket_connect()) {
#if DEBUG
		fprintf(stderr, "DEFAULT UI : cannot connect ui server\n");
#endif
		exit(1);
	}

#if DEBUG
	fprintf(stderr,
		"DEFAULT UI : pid : %d unisocket connect success, \
		ui start ok\n", getpid());
#endif
	unisocket_set_receive_handler(ime_receive_handler);
	gtk_main();

	return 0;
}
